function control() {
	this.obj = new getElement();
	this.startObj = '';
	this.againObj = '';
	this.ongoingObj = '';
	this.meet_id = '';
	this.sequence = '';
	this.gameTime= 0;
	this.getNumberTimer = '';
	this.checkBtnStatusTimer  = '',
	this.timer=null;
	this.isLock = false;
	var that;
}
control.prototype = {
	status:'',
	gameTime:'',
	get_btn_url : '/tug/bhDetails/control',
	gameStatus_url : '/tug/bhDetails/gameStart',
	gameAgain_url : '/tug/bhDetails/gameAgain',
	init:function() {
		that = this;
		that.meet_id = that.obj.getQueryString("meet_id");
	    that.sequence = that.obj.getQueryString("sequence")
	    that.startObj = that.obj.getElem("start");
		that.againObj = that.obj.getElem("again");
		that.ongoingObj = that.obj.getElem("ongoing");
		that.nobodyObj = that.obj.getElem("nobody");
		that.checkBtnStatus();//请求按钮状态
	    that.bindEvent();
	},
	//绑定事件
	bindEvent:function() {
		/**再来一次按钮绑定事件**/
		that.againObj.addEventListener("click",function() {
			that.gameAgain();
		},false);

		/**开始按钮绑定事件**/
		that.startObj.addEventListener("click",function() {
			that.gameStart();
		},false);
	},
	//绑定事件end

	//游戏开始
	gameStart:function() {
		clearInterval(that.getNumberTimer);
		var data = {
			"sequence":that.sequence,
			"meet_id":that.meet_id,
		};
		that.request_data(that.gameStatus_url,data,that._gameStartCallback,that._gameStartErrorCallback)
	},
	_gameStartCallback:function(ret){
		if(ret.recode == 1 ){
			that.nocitceScreen(1);//通知大屏开始
		} else {
			alert(ret.msg);
		}
	},
	_gameStartErrorCallback:function(){},
	//游戏开始 end

	//再来一轮
	gameAgain:function() {
		var data ={
			"sequence":that.sequence,
			"meet_id":that.meet_id,
		};
		that.request_data(that.gameAgain_url,data,that._gameAgainCallback,that._gameAgainErrorCallback);
	},
	_gameAgainCallback:function(ret){
		if(ret.recode ==1) {
			that.nocitceScreen(0);//通知大屏游戏再来一轮
		} else {
			alert(ret.msg);
		}
	},
	_gameAgainErrorCallback:function (){},
	//再来一轮 end

	//检查游戏状态
	checkBtnStatus:function(){
		that.checkBtnStatusTimer = setInterval(function(){
			that.getBtnStatus();
		},1000);
	},
	//检查游戏状态 end

	//获取按钮的状态
	getBtnStatus:function(){
		var data= {
			"sequence":that.sequence,
			"meet_id":that.meet_id,
		}
		that.request_data(that.get_btn_url,data,that._getBtnCallback,that._getBtnErrorCallback)
	},
	_getBtnCallback:function(ret){
		var btnStu = ret.status;
		if(btnStu == 0) {
			that.changeDisplay(that.nobodyObj );//人数不足
		} else if(btnStu == 1) {
			that.changeDisplay(that.startObj );//可点击的游戏开始按钮
		} else if(btnStu == 2) {
			that.changeDisplay(that.ongoingObj );//显示游戏正在进行中
		} else if(btnStu == 3) {
			that.changeDisplay(that.againObj );//显示再来一轮
		} else {
			alert(ret.msg);
		}
	},
	_getBtnErrorCallback:function(){},
	//获取按钮的状态 end

	//通知大屏
	nocitceScreen:function(value) {
        var http_server = $("input[name='httpserver']").val();
            $.ajax({
                url:http_server+"/item_play",
                dataType:"json",
                type: "post",
                data:{
                    meet_id:that.meet_id,    //年会id
                    params:value           //对应action play方法的参数key
                },
                success:function(data) {
                    if(data.code==0) {

                    }
                },
                error:function(XMLHttpRequest, textStatus, errorThrown){

                }
            });
	},
	//通知大屏 end

	//显示按钮方法
	changeDisplay:function(obj) {
		that.ongoingObj.style.display = "none";
		that.startObj.style.display = "none";
		that.nobodyObj.style.display = "none";
		that.againObj.style.display = "none";
		obj.style.display = "block";
	},
	//显示按钮方法 end

	//ajax 请求
	request_data:function(url,data,callback,errorCallback) {
		$.ajax({
			type:"post",
			url:url,
			dataType:"json",
			data:data,
			success:function(ret) {
				callback && callback(ret);
			},
			error:function() {
				errorCallback && errorCallback();
			}
		})
	}
	//ajax 请求 end
};